<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:rich="http://richfaces.org/rich"
                template="layout/template.xhtml">
                       
<ui:define name="body">
    
    <h:messages globalOnly="true" styleClass="message" errorClass="errormsg" infoClass="infomsg" warnClass="warnmsg" id="globalMessages"/>
    
    <h:form id="holeSearch" styleClass="edit">
    
        <rich:simpleTogglePanel label="Hole search parameters" switchType="ajax">
        
            <s:decorate template="layout/display.xhtml">
                <ui:define name="label">name</ui:define>
                <h:inputText id="name" value="#{holeList.hole.name}"/>
            </s:decorate>

        
        </rich:simpleTogglePanel>
        
        <div class="actionButtons">
            <h:commandButton id="search" value="Search" action="/HoleList.xhtml"/>
        </div>
        
    </h:form>
    
    <rich:panel>
        <f:facet name="header">Hole search results</f:facet>
    <div class="results" id="holeList">

    <h:outputText value="The hole search returned no results." 
               rendered="#{empty holeList.resultList}"/>
               
    <rich:dataTable id="holeList" 
                var="hole"
              value="#{holeList.resultList}" 
           rendered="#{not empty holeList.resultList}">
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="id #{holeList.order=='id asc' ? messages.down : ( holeList.order=='id desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{holeList.order=='id asc' ? 'id desc' : 'id asc'}"/>
                </s:link>
            </f:facet>
            #{hole.id}
        </h:column>
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="course id #{holeList.order=='course.id asc' ? messages.down : ( holeList.order=='course.id desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{holeList.order=='course.id asc' ? 'course.id desc' : 'course.id asc'}"/>
                </s:link>
            </f:facet>
            #{hole.course.id}
        </h:column>
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="ladiesHandicap #{holeList.order=='ladiesHandicap asc' ? messages.down : ( holeList.order=='ladiesHandicap desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{holeList.order=='ladiesHandicap asc' ? 'ladiesHandicap desc' : 'ladiesHandicap asc'}"/>
                </s:link>
            </f:facet>
            #{hole.ladiesHandicap}
        </h:column>
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="ladiesPar #{holeList.order=='ladiesPar asc' ? messages.down : ( holeList.order=='ladiesPar desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{holeList.order=='ladiesPar asc' ? 'ladiesPar desc' : 'ladiesPar asc'}"/>
                </s:link>
            </f:facet>
            #{hole.ladiesPar}
        </h:column>
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="mensHandicap #{holeList.order=='mensHandicap asc' ? messages.down : ( holeList.order=='mensHandicap desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{holeList.order=='mensHandicap asc' ? 'mensHandicap desc' : 'mensHandicap asc'}"/>
                </s:link>
            </f:facet>
            #{hole.mensHandicap}
        </h:column>
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="mensPar #{holeList.order=='mensPar asc' ? messages.down : ( holeList.order=='mensPar desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{holeList.order=='mensPar asc' ? 'mensPar desc' : 'mensPar asc'}"/>
                </s:link>
            </f:facet>
            #{hole.mensPar}
        </h:column>
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="name #{holeList.order=='name asc' ? messages.down : ( holeList.order=='name desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{holeList.order=='name asc' ? 'name desc' : 'name asc'}"/>
                </s:link>
            </f:facet>
            #{hole.name}
        </h:column>
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="number #{holeList.order=='number asc' ? messages.down : ( holeList.order=='number desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{holeList.order=='number asc' ? 'number desc' : 'number asc'}"/>
                </s:link>
            </f:facet>
            #{hole.number}
        </h:column>
        <h:column>
            <f:facet name="header">action</f:facet>
            <s:link view="/#{empty from ? 'Hole' : from}.xhtml" 
                   value="#{empty from ? 'View' : 'Select'}" 
                      id="hole">
                <f:param name="holeId" 
                        value="#{hole.id}"/>
            </s:link>
        </h:column>
    </rich:dataTable>

    </div>
    </rich:panel>
    
    <div class="tableControl">
      
        <s:link view="/HoleList.xhtml" 
            rendered="#{holeList.previousExists}" 
               value="#{messages.left}#{messages.left} First Page"
                  id="firstPage">
          <f:param name="firstResult" value="0"/>
        </s:link>
        
        <s:link view="/HoleList.xhtml" 
            rendered="#{holeList.previousExists}" 
               value="#{messages.left} Previous Page"
                  id="previousPage">
            <f:param name="firstResult" 
                    value="#{holeList.previousFirstResult}"/>
        </s:link>
        
        <s:link view="/HoleList.xhtml" 
            rendered="#{holeList.nextExists}" 
               value="Next Page #{messages.right}"
                  id="nextPage">
            <f:param name="firstResult" 
                    value="#{holeList.nextFirstResult}"/>
        </s:link>
        
        <s:link view="/HoleList.xhtml" 
            rendered="#{holeList.nextExists}" 
               value="Last Page #{messages.right}#{messages.right}"
                  id="lastPage">
            <f:param name="firstResult" 
                    value="#{holeList.lastFirstResult}"/>
        </s:link>
        
    </div>
    
    <s:div styleClass="actionButtons" rendered="#{empty from}">
        <s:button view="/HoleEdit.xhtml"
                    id="create" 
                 value="Create hole">
            <f:param name="holeId"/>
        </s:button>
    </s:div>
    
</ui:define>

</ui:composition>

